#include "main.h"
typedef  struct Queue1{
    int * front;
    int * rear;
}Queue1;
Queue1 b;
int init_queue(Queue ** q){
    (*q) = (Queue *) malloc(sizeof(Queue));
    if(!*q){
        return 1;
    }
    b.front = (*q)->elements;
    (*q)->size =0;
    b.rear = b.front;
    return 0;
};
int enqueue(Queue * q,int value){
    if(q->size>QUEUE_MAX_SIZE){
        return 1;
    }
    b.rear++;
    q->elements[q->size] = value;
    q->size++;
    return 0;
};
int dequeue(Queue * q,int *value){
    if(b.front==b.rear){
        return 1;
    }
    *value = *(b.front);
    b.front++;
    q->size--;
    return 0;
};
int first(Queue * q,int * value){
    if(b.front==b.rear){
        return 1;
    }
    *value = *(b.front);
    return 0;
}
int is_empty(Queue *q){
    if(q->size == 0)
        return 0;
    return 1;
}
int size(Queue * q){
    return q->size;
};
int main() {
    Queue *q;
    init_queue(&q);
    enqueue(q,10);
    enqueue(q,20);
    enqueue(q,30);
    int value;
    dequeue(q,&value);
    printf("Dequeued value:%d/n",value);
    first(q,&value);
    printf("First value: %d/n",value);
    printf("Queue size:%d/n", size(q));
    return 0;
}